package cn.doitedu.serde;

import org.junit.Test;

import java.io.*;
import java.util.HashMap;

public class SerDeDemo {

    @Test
    public void test1() throws Exception {

        HashMap<String, String> rules = new HashMap<>();
        rules.put("rule-001","f1+f2");

        // 序列化
        FileOutputStream out = new FileOutputStream("./rule_snapshot/rules.obj");
        ObjectOutputStream objOut = new ObjectOutputStream(out);

        objOut.writeObject(rules);

        objOut.close();
        out.close();

    }

    @Test
    public void test2() throws Exception {

        FileInputStream in = new FileInputStream("D:\\devworks\\doe50_javase_exer\\rule_snapshot\\rules.obj");
        ObjectInputStream objIn = new ObjectInputStream(in);

        HashMap<String,String> ruleMap = (HashMap<String, String>) objIn.readObject();


        System.out.println(ruleMap);

    }



}
